package dao;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Random;

public class Dao_No {

    //生成编号
    public static String getNo(){
        int length = 8;
        String prefix = "I"; // 前缀
        Random random = new Random();
        StringBuilder s = new StringBuilder();
        s.append(prefix);
        for (int i = 0; i < length - prefix.length(); i++) {
            s.append(random.nextInt(10));
        }

        return s.toString();
    }

    //生成日期
    public static String getTime()
    {
        LocalDate now = LocalDate.now();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");

        return now.format(formatter);
    }

    public static String getNo_in(){
        int length = 8;
        String prefix = "SSI"; // 前缀
        Random random = new Random();
        StringBuilder s = new StringBuilder();
        s.append(prefix);
        for (int i = 0; i < length - prefix.length(); i++) {
            s.append(random.nextInt(10));
        }

        return s.toString();
    }

    public static String getNo_out(){
        int length = 8;
        String prefix = "SSO"; // 前缀
        Random random = new Random();
        StringBuilder s = new StringBuilder();
        s.append(prefix);
        for (int i = 0; i < length - prefix.length(); i++) {
            s.append(random.nextInt(10));
        }

        return s.toString();
    }

    public static String getNo_oder(){
        int length = 8;
        String prefix = "SS"; // 前缀
        Random random = new Random();
        StringBuilder s = new StringBuilder();
        s.append(prefix);
        for (int i = 0; i < length - prefix.length(); i++) {
            s.append(random.nextInt(10));
        }

        return s.toString();
    }

}
